/**
 * 
 */
package com.xianshijian.oauth.server;

import java.net.MalformedURLException;

import org.apache.commons.io.FileUtils;
import org.dbunit.database.IDatabaseConnection;
import org.dbunit.dataset.DataSetException;
import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationContextLoader;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;

/**
 * @author ptzhuf
 *
 */
@WebAppConfiguration
@ContextConfiguration(classes = OauthServerApplicationTests.class, loader = SpringApplicationContextLoader.class)
public class AbstractSpringCucumber {

	@Autowired
	protected WebApplicationContext wac;
	protected MockMvc mvc;
	@Autowired
	private IDatabaseConnection connection;

	public IDatabaseConnection getConnection() {
		return connection;
	}

	public IDataSet getDataSet(String filename) throws MalformedURLException,
			DataSetException {

		IDataSet dataSet = new FlatXmlDataSetBuilder().build(FileUtils
				.toFile(this.getClass().getResource(filename)));
		return dataSet;
	}
}
